package com.starleague.battletech.controller.jpa.appengine;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import com.starleague.battletech.controller.AbstractServerBattletechController;
import com.starleague.battletech.game.dto.IBattletechGameDto;
import com.starleague.battletech.rules.initiative.InitiativePhaseState;
import com.starleague.battletech.rules.movement.MovementPhaseState;
import com.starleague.jpa.appengine.GaePersistManager;

@Singleton
@Named
public class BattletechControllerGae
        extends AbstractServerBattletechController<BattletechContextGae>
{
    private final GaePersistManager persistManager;

    @Inject
    public BattletechControllerGae(GaePersistManager persistManager,
                                   IBattletechGameDto gameDto,
                                   InitiativePhaseState initiativePhaseState,
                                   MovementPhaseState movementPhaseState)
    {
        super(gameDto, initiativePhaseState, movementPhaseState);
        this.persistManager = persistManager;
    }

    @Override
    protected BattletechContextGae createContext()
    {
        return new BattletechContextGae(this.persistManager.startTransaction(), this.gameDto);
    }
}
